const person1 = {
  name: "云牧",
  age: 18,
  birth: "2002-01-01",
};

//replacer 数组
console.log(JSON.stringify(person1, ["name", "age"])); // {"name":"云牧","age":18}

const person2 = {
  name: "云牧",
  age: 18,
  birth: "2002-01-01",
};

//replacer 方法
const jsonString = JSON.stringify(person2, function (key, value) {
  if (typeof value === "string") {
    return undefined;
  }
  return value;
});

console.log(jsonString); // {"age":18}

// space 美化格式
const person3 = {
  name: "云牧",
  age: 18,
  birth: "2002-01-01",
};
const a = JSON.stringify(person3);
console.log(a); // {"name":"云牧","age":18,"birth":"2002-01-01"}

const person4 = {
  name: "云牧",
  age: 18,
  birth: "2002-01-01",
};
const c = JSON.stringify(person4, null, "\t");
console.log(c);
// {
// 	"name": "云牧",
// 	"age": 18,
// 	"birth": "2002-01-01"
// }
